// pages/add/add.js
const db = wx.cloud.database()
const productsCollection = db.collection('products')

Page({
    data: {
        form: {
            title: '',
            color: '',
            image: '',
          }
    },
    changeFrom (e) {
        this.setData({
          [`form.${e.currentTarget.dataset.model}`]: e.detail
        })
        console.log(this.data.form);
    },
    AddData:function(event){
        console.log(event)
        var getdata = this.data.form
        productsCollection.add({
            data:{
                title: this.data.form.title,
                image:this.data.form.image,
                color:this.data.form.color
            },
            success:res=>
            {
                console.log(res)
            }
        }
        )
       
    }
})